extends layout

block content
  .post
    h1
      =post.title
    p.meta Posted in
      span.tag
        a(href='/categories/show/' + post.categoryId) &nbsp; #{ post.category_title } &nbsp;
      span   on #{dayjs(post.created_at).format("MM-DD-YYYY")}
    img.thumb(src=post.thumbimage)
    .body
      !=post.content
    div.btn-group.pull-right
      a.btn(href='/api/posts/delete/'+ post.id, data-confirm="Are you sure?") Destroy &nbsp;
        span.glyphicon.glyphicon-trash
      a.btn(href='/posts/edit/'+ post.id) Edit &nbsp;
        span.glyphicon.glyphicon-pencil
  .comments
    if errors
      ul.errors
        each error, i in errors
          li.alert.alert-danger #{error.msg}
    form.comment-form(method='post', action='/api/posts/addcomment')
      input(name='postId', type='hidden', value=post.id)
      input(name='ownerId', type='hidden', value=post.userId)
      .form-group
        textarea.form-control(name='text', id='text')
      input.btn.btn-default(name='submit', type='submit', value='Submit Comment')
    <hr />
    if post.comments
      h3 Comments (#{post.comments.length})
      each comment, i in post.comments
        .box
          .group
            label Comment:
            p.body #{comment.text}
          .meta
            p By #{comment.username} on #{dayjs(comment.create_at).format("hh:mm:ss MM-DD-YYYY")}
